<template>
  <div class="login-container">
    <input v-model="businessId" placeholder="商家ID">
    <input type="password" v-model="password" placeholder="密码">
    <button @click="login">登录</button>
	
	<div class="register-link">
	      还没有账号？<router-link to="/businessRegister">立即注册</router-link>
	</div>
  </div>
</template>

<script>
export default {
  data() {
    return { businessId: '', password: '' }
  },
  methods: {
    login() {
      this.$axios.post('BusinessController/businessLogin', this.$qs.stringify({
        businessId: this.businessId,
        password: this.password
      })).then(response => {
        if (response.data) {
          this.$setSessionStorage('business', response.data);
          this.$router.push('/businessHome');
        } else {
          alert('登录失败');
        }
      });
    }
  }
}
</script>